/*
 * ShapeButtonTriangleSkin.fx
 *
 * Created on 18/05/2009, 16:55:34
 */

package webooksfx_desktop.view.components;

import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.scene.CustomNode;
import javafx.scene.effect.Glow;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polyline;

/**
 * @author matias
 */

public class ShapeButtonTriangleSkin extends CustomNode {
	public var color: Color = Color.GOLD;
	public var x: Integer = 0;
	public var y: Integer = 0;

	public var action: function() : Void;

	var effect_button: Glow = Glow {
		level: 0
	};
	var timeline_button: Timeline = Timeline {
		repeatCount: Timeline.INDEFINITE
		keyFrames: [
			KeyFrame {
				time: 0s
				values: bind effect_button.level => 0
			},
			KeyFrame {
				time: 0.5s
				values: bind effect_button.level => 1
			},
			KeyFrame {
				time: 1s
				values: bind effect_button.level => 0
			}
		]
	}
	var shape: Polyline = Polyline {
		points: [ 0,0, 15,10, 0,20, 0,0 ]
		fill: bind color
		strokeWidth: 2.0
		stroke: bind color
		effect: bind effect_button
	}

	public override function create(): Node {
		return Group {
			content: {
				AbstractButton {
					x: bind x, y: bind y
					timeline_button: timeline_button
					content_button: shape
					action: action
				}
			}
		};
	}
}